﻿#pragma once
#include "MyTask.g.h"
#include <winrt/base.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.ApplicationModel.AppService.h>
#include <winrt/Windows.ApplicationModel.Background.h>
#include <winrt/Windows.Networking.Sockets.h>
#include <winrt/Windows.Networking.BackgroundTransfer.h>
#include <winrt/Windows.UI.Notifications.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.System.Threading.h>
#include <winrt/Windows.Networking.Sockets.h>
#include <winrt/Windows.Networking.h>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.Storage.FileProperties.h>
#include <winrt/Windows.Storage.AccessCache.h>
#include <winrt/Windows.Storage.Streams.h>
#include <winrt/Windows.Data.Json.h>
#include <winrt/Windows.Data.Xml.Dom.h>
#include <winrt/Windows.Security.Cryptography.Certificates.h>

namespace winrt::RuntimeComponent2::implementation
{
    struct MyTask : MyTaskT<MyTask>
    {
        MyTask() = default;
        bool connected = false;

        void Run(winrt::Windows::ApplicationModel::Background::IBackgroundTaskInstance const& taskInstance);
        
        winrt::Windows::Foundation::IAsyncAction HeartBeatAsync(winrt::Windows::System::Threading::ThreadPoolTimer timer);
        winrt::Windows::Foundation::IAsyncAction StartDownloadAsync(winrt::hstring token, winrt::hstring path);
        winrt::Windows::Foundation::IAsyncAction StartUploadAsync(winrt::hstring token, winrt::hstring path);

        // void UpdateNotification(const Windows::Networking::BackgroundTransfer::UploadOperation& upload);
        // void UpdateNotification(const Windows::Networking::BackgroundTransfer::DownloadOperation& download);
        winrt::Windows::Networking::Sockets::StreamSocket socket{ nullptr };
        void NotifyConnect();
        void NotifyDisconnect();
    };
}

namespace winrt::RuntimeComponent2::factory_implementation
{
    struct MyTask : MyTaskT<MyTask, implementation::MyTask>
    {
    };
}